package com.mio.web.service.sys;

import java.util.List;

import org.durcframework.core.expression.ExpressionQuery;
import org.durcframework.core.expression.subexpression.ValueExpression;
import org.durcframework.core.service.CrudService;
import org.springframework.stereotype.Service;

import com.mio.web.dao.sys.SysUploadDao;
import com.mio.web.entity.sys.SysUpload;



@Service
public class SysUploadService extends CrudService<SysUpload, SysUploadDao> {
	
	/**
	 * 根据功能模块Id查询该模块中第一条数据
	 * @param funcId
	 * @return
	 */
	public SysUpload getFirstSysUploadByFuncId(String funcId){
		ExpressionQuery query = new ExpressionQuery();
		query.add(new ValueExpression("funcId", funcId));
		query.add(new ValueExpression("isDeleted", 0));
		query.setLimit(1);
		query.addSort("sortId");
		List<SysUpload> upload = this.find(query);
		if(upload != null && upload.size()>0){
			return upload.get(0);
		}
		return null;
	}
	
	/**
	 * 根据功能模块Id和数量查询该模块中对应数据
	 * @param funcId
	 * @return
	 */
	public List<SysUpload> getNumsSysUploadByFuncId(String funcId,int num){
		ExpressionQuery query = new ExpressionQuery();
		query.add(new ValueExpression("funcId", funcId));
		query.add(new ValueExpression("isDeleted", 0));
		query.setLimit(num);
		query.addSort("sortId");
		List<SysUpload> upload = this.find(query);
		if(upload != null && upload.size()>0){
			return upload;
		}
		return null;
	}
}